<html>
<head><meta charset="utf-8"><title>Omitting `unsafe` in trait impls RFC · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html">Omitting `unsafe` in trait impls RFC</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230731345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230731345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230731345">(Mar 17 2021 at 17:19)</a>:</h4>
<p>Opening a stream to chat with @scottmcm.</p>



<a name="230731358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230731358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230731358">(Mar 17 2021 at 17:19)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span></p>



<a name="230731395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230731395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230731395">(Mar 17 2021 at 17:19)</a>:</h4>
<p><span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="230731526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230731526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230731526">(Mar 17 2021 at 17:20)</a>:</h4>
<p>RE: whether or not callers should be allowed to omit <code>unsafe</code>, I'd be curious to hear more about your thoughts</p>



<a name="230732834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230732834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230732834">(Mar 17 2021 at 17:28)</a>:</h4>
<p>Semantically I think it makes complete sense.  Mostly I'm just pondering semver implications.  (Whereas for <code>const</code> those don't exist because it's semver-ok to add the <code>const</code> later.)</p>
<p>But that also opens some questions about using things.  Like if we'll have <code>impl const Default</code>, then does it make sense to have <code>impl Default for Foo { const fn default() -&gt; Self { ... } }</code>?  Would we want something like that for <code>unsafe</code>?</p>



<a name="230761787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230761787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230761787">(Mar 17 2021 at 20:35)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I actually thought that was already plan-of-record for <code>const fn</code>, but I guess it has now been relegated to an "alternative" in <a href="https://github.com/oli-obk/rfcs/blob/const_generic_const_fn_bounds/text/0000-const-generic-const-fn-bounds.md#fine-grained-const-annotations">https://github.com/oli-obk/rfcs/blob/const_generic_const_fn_bounds/text/0000-const-generic-const-fn-bounds.md#fine-grained-const-annotations</a></p>



<a name="230761858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230761858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230761858">(Mar 17 2021 at 20:35)</a>:</h4>
<p>That is, I had assumed that, yes, it would be possible to mark individual methods in a trait impl as <code>const</code></p>



<a name="230761928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230761928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230761928">(Mar 17 2021 at 20:35)</a>:</h4>
<p>we just don't have a syntax for expressing a generic bound on such a thing, similar to how we don't have syntax for expressing the equivalent <code>unsafe</code>-ness bound</p>



<a name="230762000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230762000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230762000">(Mar 17 2021 at 20:36)</a>:</h4>
<p>I think it's still a useful feature in both cases even if it's limited to non-generic methods</p>



<a name="230952457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/230952457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#230952457">(Mar 18 2021 at 23:25)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> trying to bring this to a conclusion so we can give a response on the RFC thread: do you currently feel opposed to the idea of merging the RFC as-is? Do you feel like there is missing information that would help you make that decision?</p>



<a name="231861280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/231861280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#231861280">(Mar 25 2021 at 19:22)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> checking if you had a chance to think this over more</p>



<a name="232534844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/232534844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#232534844">(Mar 31 2021 at 04:29)</a>:</h4>
<p>Would we expect the RFC to include allowing specifying <code>const</code> even if it's not an <code>impl const Foo</code>?  With the same kind of rules?  (so I can <code>impl Default for Foo { const fn default() -&gt; Self { ... } }</code> and use <code>Foo::default()</code> in const context.)</p>



<a name="232534935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Omitting%20%60unsafe%60%20in%20trait%20impls%20RFC/near/232534935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Omitting.20.60unsafe.60.20in.20trait.20impls.20RFC.html#232534935">(Mar 31 2021 at 04:30)</a>:</h4>
<p>Having slept on it I think I'm good with the "well, adding <code>unsafe</code> is always a breaking change, so it's fine if it is here too" argument.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>